<?php
namespace Home\Controller;
use Think\Controller;
class SetalertController extends Controller {

    public function getdata(){
        if(IS_POST){
            $data=D('macalert')->where(array('valid'=>1))->select();
            $this->ajaxReturn(array('data'=>$data), 'JSON');
        }
    }

    public function save(){
        if(IS_POST){
            $map['mac']=I('post.mac');
            $map['alertname']=I('post.alertname');
            if(I('post.types')=='edit'){
                $data=D('macalert')->where(array('id'=>I('post.id')))->save($map);
            }else if(I('post.types')=='add'){
                $data=D('macalert')->add($map);
            }else{
                $data=D('macalert')->where(array('id'=>I('post.id')))->delete();
            }

            $this->ajaxReturn(array('status'=>true), 'JSON');
        }
    }
    public function setalert(){

        $this->assign('title','目标出现告警设置');
        $this->assign('currentname','setalert');
        $this->display();
    }
}